guess-image-layout
Guess the Layout of Image Pixels. Returns layout in xdim layout syntax.
install
npm install guess-image-layout
basic usage
import guessImageLayout from "guess-image-layout";
const rgba = [123, 234, 42, 255, 124, 42, 42, 255, ...];
guessImageLayout({ data: rgba, bands: 4, height: 768 });
const bands = [
[123, 124, ...],
[234, 42, ...],
[42, 42, ...],
[255, 255, ...]
];
guessImageLayout({ data: bands });
advanced usage
If you already know the array of layout of the data, you can pass that in and it will calculate what it can.
import guessImageLayout from "guess-image-layout";
const rgba = [123, 234, 42, 255, 124, 42, 42, 255, ...];
guessImageLayout({ data: rgba, layout: "[band][row,column]" })